<?php
class Trangchu extends CI_Controller {
	public $data;
	public function __construct()
	{
		parent::__construct();
	    $this->load->model(array('admin/m_giangvien','admin/m_baigiang','admin/m_mon','user_model'));
        $this->is_logged_in();
        $this->isTeacher();
        $this->isAdmin();
	}
    function is_logged_in()
	{
		$is_logged_in = $this->session->userdata('logged_in');
		if(!isset($is_logged_in) || $is_logged_in != true)
		{
            return false;	
		}		
        else
        {
            return true;
        }
	}
    function isAdmin(){
        $isAdmin = $this->session->userdata('isAdmin');
        if($isAdmin == '' || $isAdmin != 'isAdmin')
		{
            return false;	
		}		
        else
        {
            return true;
        }
    }
    function isTeacher(){
        $isTeacher = $this->session->userdata('isTeacher');
        if($isTeacher == '' || $isTeacher != 'isTeacher')
		{
            return false;	
		}		
        else
        {
            return true;
        }
    }
	
	public function index()
	{
        if($this->isAdmin()){
            $this->data['title']="Trang Quản Trị Web Site.";
            $this->load->view('admin/index',$this->data);
        }else{
            echo 'Bạn không có quyền vào đây!!!';
            //redirect('','refresh');
        }
        $this->load->view('admin/index',$this->data);
	}
}
?>
